{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Forward  Stepwise Selection"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from sklearn.linear_model import LinearRegression\n",
    "from sklearn.metrics import r2_score,adjusted_rand_score\n",
    "\n",
    "import statsmodels.api as sm\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(400, 11)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Income</th>\n",
       "      <th>Limit</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Cards</th>\n",
       "      <th>Age</th>\n",
       "      <th>Education</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Student</th>\n",
       "      <th>Married</th>\n",
       "      <th>Ethnicity</th>\n",
       "      <th>Balance</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>14.891</td>\n",
       "      <td>3606</td>\n",
       "      <td>283</td>\n",
       "      <td>2</td>\n",
       "      <td>34</td>\n",
       "      <td>11</td>\n",
       "      <td>Male</td>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Caucasian</td>\n",
       "      <td>333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>106.025</td>\n",
       "      <td>6645</td>\n",
       "      <td>483</td>\n",
       "      <td>3</td>\n",
       "      <td>82</td>\n",
       "      <td>15</td>\n",
       "      <td>Female</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Asian</td>\n",
       "      <td>903</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>104.593</td>\n",
       "      <td>7075</td>\n",
       "      <td>514</td>\n",
       "      <td>4</td>\n",
       "      <td>71</td>\n",
       "      <td>11</td>\n",
       "      <td>Male</td>\n",
       "      <td>No</td>\n",
       "      <td>No</td>\n",
       "      <td>Asian</td>\n",
       "      <td>580</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>148.924</td>\n",
       "      <td>9504</td>\n",
       "      <td>681</td>\n",
       "      <td>3</td>\n",
       "      <td>36</td>\n",
       "      <td>11</td>\n",
       "      <td>Female</td>\n",
       "      <td>No</td>\n",
       "      <td>No</td>\n",
       "      <td>Asian</td>\n",
       "      <td>964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>55.882</td>\n",
       "      <td>4897</td>\n",
       "      <td>357</td>\n",
       "      <td>2</td>\n",
       "      <td>68</td>\n",
       "      <td>16</td>\n",
       "      <td>Male</td>\n",
       "      <td>No</td>\n",
       "      <td>Yes</td>\n",
       "      <td>Caucasian</td>\n",
       "      <td>331</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Income  Limit  Rating  Cards  Age  Education  Gender Student Married  \\\n",
       "1   14.891   3606     283      2   34         11    Male      No     Yes   \n",
       "2  106.025   6645     483      3   82         15  Female     Yes     Yes   \n",
       "3  104.593   7075     514      4   71         11    Male      No      No   \n",
       "4  148.924   9504     681      3   36         11  Female      No      No   \n",
       "5   55.882   4897     357      2   68         16    Male      No     Yes   \n",
       "\n",
       "   Ethnicity  Balance  \n",
       "1  Caucasian      333  \n",
       "2      Asian      903  \n",
       "3      Asian      580  \n",
       "4      Asian      964  \n",
       "5  Caucasian      331  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv(r'E:\\programming\\dataset\\Into_to_statstical_learning\\Credit.csv',index_col=0)\n",
    "print(data.shape)\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "gender_encoding = {'Male':1,'Female':0}\n",
    "ethnicity = pd.get_dummies(data['Ethnicity'],drop_first=True)\n",
    "yes_no_encoding = {'Yes':1,'No':0}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "data['Gender'] = data['Gender'].map(gender_encoding)\n",
    "data['Student'] = data['Student'].map(yes_no_encoding)\n",
    "data['Married'] = data['Married'].map(yes_no_encoding)\n",
    "data.drop('Ethnicity',axis = 1,inplace = True)\n",
    "data = pd.concat([data,ethnicity],axis = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Income</th>\n",
       "      <th>Limit</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Cards</th>\n",
       "      <th>Age</th>\n",
       "      <th>Education</th>\n",
       "      <th>Gender</th>\n",
       "      <th>Student</th>\n",
       "      <th>Married</th>\n",
       "      <th>Balance</th>\n",
       "      <th>Asian</th>\n",
       "      <th>Caucasian</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>14.891</td>\n",
       "      <td>3606</td>\n",
       "      <td>283</td>\n",
       "      <td>2</td>\n",
       "      <td>34</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>333</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>106.025</td>\n",
       "      <td>6645</td>\n",
       "      <td>483</td>\n",
       "      <td>3</td>\n",
       "      <td>82</td>\n",
       "      <td>15</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>903</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>104.593</td>\n",
       "      <td>7075</td>\n",
       "      <td>514</td>\n",
       "      <td>4</td>\n",
       "      <td>71</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>580</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>148.924</td>\n",
       "      <td>9504</td>\n",
       "      <td>681</td>\n",
       "      <td>3</td>\n",
       "      <td>36</td>\n",
       "      <td>11</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>964</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>55.882</td>\n",
       "      <td>4897</td>\n",
       "      <td>357</td>\n",
       "      <td>2</td>\n",
       "      <td>68</td>\n",
       "      <td>16</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>331</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Income  Limit  Rating  Cards  Age  Education  Gender  Student  Married  \\\n",
       "1   14.891   3606     283      2   34         11       1        0        1   \n",
       "2  106.025   6645     483      3   82         15       0        1        1   \n",
       "3  104.593   7075     514      4   71         11       1        0        0   \n",
       "4  148.924   9504     681      3   36         11       0        0        0   \n",
       "5   55.882   4897     357      2   68         16       1        0        1   \n",
       "\n",
       "   Balance  Asian  Caucasian  \n",
       "1      333      0          1  \n",
       "2      903      1          0  \n",
       "3      580      1          0  \n",
       "4      964      1          0  \n",
       "5      331      0          1  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "features = [col for col in data.columns if not col == 'Balance']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def forward_stepwise_selection(data,target):\n",
    "    total_features = [[]]\n",
    "    score_dict = {}\n",
    "    remaining_features = [col for col in data.columns if not col == target]\n",
    "    for i in range(1,len(data.columns)):\n",
    "        best_score = 0;best_feature = None\n",
    "        for feature in remaining_features:\n",
    "\n",
    "            X = total_features[i-1] + [feature]\n",
    "            model = LinearRegression().fit(data[X],data[target])\n",
    "            score = r2_score(data[target],model.predict(data[X]))\n",
    "#             print('For len {}, feature - {}, score is {}'.format(i,feature,score))\n",
    "\n",
    "            if score > best_score:\n",
    "                best_score = score\n",
    "                best_feature = feature\n",
    "        total_features.append(total_features[i-1] + [best_feature])\n",
    "        remaining_features.remove(best_feature)\n",
    "        score_dict[i] = best_score\n",
    "    return total_features,score_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "total_predictors,score_dict = forward_stepwise_selection(data,'Balance')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Lenovo\\Anaconda3\\lib\\site-packages\\seaborn\\axisgrid.py:230: UserWarning: The `size` paramter has been renamed to `height`; please update your code.\n",
      "  warnings.warn(msg, UserWarning)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1, 'Forward Selection')"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 864x432 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAFwCAYAAACGt6HXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3deXxdd33m8c+jXd6d2A7xFmexnQQIhJhASkMctriFkjS0NJnSKZSStlMopSSFtGzDlCFMpjMwHVqaUkihFMZNQpoyGVzAStKyJHHjLNixJGMn8SrJ8SbJtmRJ3/njHNnX15J1Jd17j670vF+v+9LZ7jnfI0uPj37nd39HEYGZmZVfVdYFmJlNVQ5gM7OMOIDNzDLiADYzy4gD2MwsIw5gM7OMOIBtSpK0WtLOEux3maSQVFPk/S6V1CWpupj7tWw5gG3cJD0n6WgaEIOvhVnXNR6Srpf0pKTDkvZJ+oGkZWU8/nOS3jQ4HxEvRMSMiOgvVw1WekX9X9qmtF+KiO+P9c2SaiKir5gFjXXfki4CvgbcCKwHZgBvAQZKUZ9NXb4CtpKS9HZJmyQdlPSQpEty1j0n6SOSnga6Jb1P0j/nrN8qa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4CBntj3AU8LekbkTza6m7gMZL/TL4cERuH2Nci4KG0KeTu9JxtgvFoaGYjSJs0bo2It2Vdi00uvgI2M8uIr4DNzDLiK2Azs4w4gM3MMuIANjPLiAPYzCwjDmAzs4z8f/cxLMxdEQWiAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "temp = pd.DataFrame({'Number of predictors':list(score_dict.keys()),'R2_Score':list(score_dict.values())})\n",
    "plt.figure(figsize = (12,6))\n",
    "g = sns.FacetGrid(data = temp,size=5)\n",
    "g.map(plt.scatter, 'Number of predictors' , 'R2_Score')\n",
    "g.map(plt.plot, 'Number of predictors', 'R2_Score')\n",
    "plt.title('Forward Selection')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Subset of size 0 is []\n",
      "Subset of size 1 is ['Rating']\n",
      "Subset of size 2 is ['Rating', 'Income']\n",
      "Subset of size 3 is ['Rating', 'Income', 'Student']\n",
      "Subset of size 4 is ['Rating', 'Income', 'Student', 'Limit']\n",
      "Subset of size 5 is ['Rating', 'Income', 'Student', 'Limit', 'Cards']\n",
      "Subset of size 6 is ['Rating', 'Income', 'Student', 'Limit', 'Cards', 'Age']\n",
      "Subset of size 7 is ['Rating', 'Income', 'Student', 'Limit', 'Cards', 'Age', 'Gender']\n",
      "Subset of size 8 is ['Rating', 'Income', 'Student', 'Limit', 'Cards', 'Age', 'Gender', 'Asian']\n",
      "Subset of size 9 is ['Rating', 'Income', 'Student', 'Limit', 'Cards', 'Age', 'Gender', 'Asian', 'Married']\n",
      "Subset of size 10 is ['Rating', 'Income', 'Student', 'Limit', 'Cards', 'Age', 'Gender', 'Asian', 'Married', 'Caucasian']\n",
      "Subset of size 11 is ['Rating', 'Income', 'Student', 'Limit', 'Cards', 'Age', 'Gender', 'Asian', 'Married', 'Caucasian', 'Education']\n"
     ]
    }
   ],
   "source": [
    "for i,feature in enumerate(total_predictors):\n",
    "    print('Subset of size {} is'.format(i), feature)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Choosing the best model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "score_dict = {}\n",
    "for i,feature in enumerate(total_predictors[1:]):\n",
    "    X = data[feature]\n",
    "    y = data['Balance']\n",
    "    X = sm.add_constant(X)\n",
    "    result = sm.OLS(y, X).fit()\n",
    "    score_dict[i+1] = result.rsquared_adj"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1, 'Chossing the best model')"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 864x432 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWAAAAFwCAYAAACGt6HXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3de3xddZ3u8c+TNOn9nrZAS2mBtogycqmKolDwAjoOIHgBL6OOjmfmiDJemJE5jnI4M0c8qOPMOd7QIygyMAgMMhy0oqTgBYEq10KTlAL2Akl6JSltrt/zx1ppd9Mke6fdOyt753m/Xnllr8te67uS5unav/Vbv6WIwMzMRl5V1gWYmY1VDmAzs4w4gM3MMuIANjPLiAPYzCwjDmAzs4w4gO0Akq6Q9KMR3N8aSStGaF/XSfrHIm1rlaSPFmNbo8VwfveVePwjzQE8Rkl6r6TVktolPS/pp5Jen0UtEfHyi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0lQ/hT4q4jYQ/IopCeBP6Tdur5Dnk91kTwx4XKgHngU+ENEFDJ84f0ko249ATwD/McA2+4E3gl8WdKjwCPsG3f3w8A30otwuwfZxz8CM9MLZ48Cfb0xrgEek3RDJI+2ug54kOQ/k+9FxMMDbGs+sCptCrkuPWYbZTwamlkeaZPGZyPi7VnXYpXFZ8BmZhnxGbCZWUZ8BmxmlhEHsJlZRhzAZmYZcQCbmWXEAWxmlpH/D6Y+QSz4f6PgAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "temp = pd.DataFrame({'Number of predictors':list(score_dict.keys()),'Adjusted_R2_Score':list(score_dict.values())})\n",
    "plt.figure(figsize = (12,6))\n",
    "g = sns.FacetGrid(data = temp,size=5)\n",
    "g.map(plt.scatter, 'Number of predictors' , 'Adjusted_R2_Score')\n",
    "g.map(plt.plot, 'Number of predictors', 'Adjusted_R2_Score')\n",
    "plt.title('Chossing the best model')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1: 0.7452098462445803,\n",
       " 2: 0.8744888189724805,\n",
       " 3: 0.9494990734177157,\n",
       " 4: 0.9517033272701592,\n",
       " 5: 0.9535788787498292,\n",
       " 6: 0.9539960984035273,\n",
       " 7: 0.9540098163629883,\n",
       " 8: 0.9539649480880468,\n",
       " 9: 0.9539242850304841,\n",
       " 10: 0.9538912342742093,\n",
       " 11: 0.9538286695430547}"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
